﻿using AppManager.DomainModel;
using AppManager.Model;
using AutoMapper;

namespace AppManager.Background
{
    /// <summary>
    ///     automapper中排除那些屬性是關鍵
    /// </summary>
    public class Sys_UserProfile : Profile
    {
        protected override void Configure()
        {
            ///前面的后面的转化
            var map1 = CreateMap<Sys_User, Sys_UserEidtModel>();

            map1.ConstructUsing(s => new Sys_UserEidtModel
            {
                LoginName = s.LoginName,
                LoginPwd = string.Empty,
                LoginPwd2 = string.Empty,
                Name = s.Name
            });

            //Sys_UserEidtModel 轉化Sys_User
            var map2 = CreateMap<Sys_UserEidtModel, Sys_User>();
            map2.ConstructUsing(s => new Sys_User
            {
                LoginName = s.LoginName,
                Name = s.Name,
                Id = s.Id
            });
        }
    }
}